package liuch.iterator;

import java.util.*;

/**
 * 〈一句话功能简述〉<br>
 * 迭代器基本认识
 *
 * @author 17101651 on 2018/5/17.
 * @see [相关类/方法]（可选）
 * @since [产品/模块版本] （可选）
 */
public class InterfaceVsIterator {
    private static void display(Iterator<String> it) {
        while (it.hasNext()) {
            String s = it.next();
            System.out.print(s);
            System.out.print("|");
        }
    }

    private static void display(Collection<String> cs) {
        for (String s : cs) {
            System.out.print(s);
            System.out.print("|");
        }
    }

    public static void main(String[] args) {
        Map<String, String> map = new HashMap<String, String>();
        map.put("1", "1");
        map.put("2", "2");
        map.put("3", "3");
        map.put("4", "4");
        map.put("5", "5");
        map.put("6", "6");
        display(map.keySet());
        display(map.values());
        display(map.values().iterator());
    }
}
